import time


def timer(label='', trace=True):
    def onDecorator(func):        
        def onCall(*pargs, **kargs):                        
            start = time.perf_counter()
            result = func(*pargs, *kargs)
            elapsed = time.perf_counter() - start
            onCall.alltime += elapsed
            if trace:
                format = '%s %s: %.5f, %.5f'
                values = (label, func.__name__, elapsed, onCall.alltime)
                print(format % values)
            return result
        onCall.alltime = 0
        return onCall
    return onDecorator
    
@timer('function')
def listcomp(N):
    return [x*2 for x in range(N)]


listcomp(1000002)


class Person:
    def __init__(self, name, pay):
        self.name = name
        self.pay = pay

    @timer('method - giveRaise')
    def giveRaise(self, percent):
        self.pay *= (1.0 + percent)

    @timer('method - display')
    def display(self):
        return self.pay

bob = Person('Bob Smith', 60000)
bob.display()
bob.giveRaise(0.2)
bob.display()